import java.util.Arrays;

public class Test1 {
    //leectode 179 最大数
    public String largestNumber(int[] nums) {
        int n = nums.length;
        //将数组中的元素都转换为字符串
        String[] s = new String[n];
        for (int i = 0; i < n; i++) s[i] = "" + nums[i];
        Arrays.sort(s,(a, b) ->
                (b + a).compareTo(a + b));
        StringBuilder sb = new StringBuilder();
        for (String t : s) sb.append(t);
        if (sb.charAt(0) == '0') return "0";
        return sb.toString();
    }
}
